package org.dna.uimodel;

import org.tigris.scarab.model.Activity;

/**
 * Internal usage Decorator class to wrap an activity and make it selectable.
 *
 * */
public final class SelectableActivity extends Activity {
    //NB all setter must be redefined else the changes doesnt' go in the wrapped
    //object

    private static final long serialVersionUID = 5979664854609004460L;
    private Activity m_orig;
    private boolean selected = false;

    public SelectableActivity(Activity orig) {
        super();
        m_orig = orig;
    }

    public boolean isSelected() {
        return selected;
    }

    void setSelected(boolean selected) {
        this.selected = selected;
    }

    @Override
    public Long getActivityId() {
        return m_orig.getActivityId();
    }

//    @Override
//    public List<Job> getJobs() {
//        return m_orig.getJobs();
//    }

    @Override
    public String getDescription() {
        return m_orig.getDescription();
    }

    @Override
    public void setDescription(String descr) {
        m_orig.setDescription(descr);
    }

    @Override
    public String toString() {
        return String.format("sel=%b %s", selected, m_orig);
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final SelectableActivity other = (SelectableActivity) obj;
        if (this.m_orig == null || !this.m_orig.equals(other.m_orig)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        return hash;
    }
}
